package com.movies.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MVCConfig implements WebMvcConfigurer {
    //拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        /*registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**").excludePathPatterns("/");*/
    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/")
                .setViewName("login");

//        registry.addViewController("/index").setViewName("index");
    }
    //解决图片需要重启才能访问的问题
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        System.out.println("配置已启动");
        registry.addResourceHandler("/static/pages/img/**")
                .addResourceLocations("file:D:\\javakf\\movie-sales\\src\\main\\resources\\static\\pages\\img\\");
            }


}
